package com.software.task.pojo;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Transient;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Set;
/**
 * @author 浦慧慧
 * @since 2024/12/15 11.34
 * @version 1.0
 */
@Entity

@Data
public class User {
    /**
     * 用户ID
     * 密码
     * 昵称
     * 电子邮件
     * 用户头像的图片链接
     * 创建时间
     * 更新时间
     * 用户状态,权限信息
     * 角色ID
     * 角色
     */
    @Id
    @NotNull
    @TableId(value="id",type= IdType.AUTO)
    @ExcelIgnore
    private Integer id;
    @Pattern(regexp = "^\\S{2,30}$", message = "用户名必须是2到30个非空白字符")
    @ExcelProperty(value = "姓名")
    private String username;

    /**
     * 密码
     */
    @Pattern(regexp = "^\\S{5,30}$", message = "密码必须是5到16个非空白字符")
    @ExcelIgnore
    private String password;
    @NotEmpty
    @Pattern(regexp = "^\\S{1,10}$")
    @ExcelProperty(value = "昵称")
    private String nickname;
    @Transient
    @TableField(exist = false)
    private Set<Permission> permissions;
    @TableField(exist = false)
    private String roleId;
    @Transient
    @TableField(exist = false)
    @ExcelProperty(value = "角色")
    private List<Role> roles;
    /**
     * 电子邮箱
     * 用户头像
     * 创建时间
     * 更新时间
     */
    @NotEmpty
    @Email
    @ExcelProperty(value = "电子邮件")
    private String email;
    @ExcelProperty(value = "头像图片")
    private String userPic;
    @ExcelProperty(value = "创建时间")
    private LocalDateTime createTime;
    @ExcelProperty(value = "更新时间")
    private LocalDateTime updateTime;
    public User() {}
}
